#Include "Totvs.ch"

CLASS TImpPedMer FROM LongClassName
	DATA cPath AS STRING READONLY
	DATA cExt AS STRING READONLY
	DATA cClassName AS STRING READONLY
	DATA oPedidos AS TEFWList
	METHOD New(cPath, cExt) CONSTRUCTOR
	METHOD ClassName()
	METHOD Load()
	METHOD IncPed()
ENDCLASS

//-----------------------------------------------------------------
METHOD New(cPath, cExt) CLASS TImpPedMer
	DEFAULT cPath := GetSrvProfString("Startpath", "") + "Mercador\IN\"
	DEFAULT cExt := "*.EDI"
	cClassName := "TImpPedMer"
	oPedidos := TEFWList():New()
	::cPath := cPath
	::cExt := cExt
RETURN SELF
//-----------------------------------------------------------------
METHOD ClassName() CLASS TImpPedMer
RETURN (::cClassName)

//-----------------------------------------------------------------
METHOD Load() CLASS TImpPedMer
	LOCAL aPedidos := Directory(::cPath + ::cExt)
	LOCAL oPedido := Nil
	LOCAL cVal := ""
	
	FOR nI := 1 TO LEN(aPedidos)
		cVal := MemoRead(::cPath + aPedidos[nI, 1])
		oPedido := TPedMerc():ImpPed(cVal)
		oPeido:SetNomArq(aPedidos[nI, 1])
		::oPedidos:Add(oPedido)
	NEXT nI
	
RETURN NIL

//-----------------------------------------------------------------